RE: Bug in gethostbyaddr() on some systems

Chiaki Ishikawa (ishikawa@personal-media.co.jp)
Sat, 4 Mar 1995 07:03:01 +0900

PMC e-mail id: 3523 

(1) (Yesterday, our mail gateway had trouble delivering mails.
If the bugtraq list received bounced mails, my apologies.
It is working now. I have been monitoring the sendmail log all night
long. sigh...)

(2) I am very new to this list.

    Is there a digest version of bugtraq list? If there is, how can I
subscribe to the digest version?

(3) A little contribution.

A few days ago, somebody posted a res.c source code mentioning a
potential bug on DEC alpha and HP-UX regarding the incorrect or
invalid field returned by gethostbyaddr().

I got curious and compiled the posted code on SunOS 4.0.3.
It is very old system.
(I needed to include <ctype.h> and needed to add strcasecmp.c from BSD 
44lite distribution to compile res.c using Sun's CC).

I linked the code with resolv-2.1.1 package (often called resolv+ library.)
(from README of resolv-2.1.1:
This is resolv+ 2.1, a modified version of the resolver library
from BIND 4.8.3.)

Since I couldn't change the /etc/resolv.conf, I used the environment
variable RESOLV_SERV_ORDER to change the order of nis,hosts search
before execution. (We don't run bind on the internal LAN.)

The following is the strange(?) result I got.

It looks that the NIS code or the code in resolv+, which in turn is
probably in the recent BIND, doesn't handle the middle-of-the-line
comment '#' which seems to be understood by the routine(s) that looks
at /etc/hosts directly.

In the following script output, 
host,nis search order seems to produce correct (expected) result.

But the nis,host order produced strange result: '#' is not treated as 
comment, but as valid aliases as well as the following comments are!!!
This will certainly make things confused.

The data is on an isolated LAN. So the IP address is not a registered one.

Script started on Sat Mar  4 06:40:30 1995 <=== (Early in the morning).
sun00!/usr2/tmp-1%  cat /etc/motd
SunOS Release 4.0.3-JLE1.0.3 (GENX) #1: Sat Aug 18 15:19:10 JST 1990

(hosts,nis order)
sun00!/usr2/tmp-2%  env RESOLV_SERV_ORDER=hosts,nis a.out 192.9.200.2
Canonical name sun02	
aliases:			<=== output seems OK.
  nonstop	

(now nis,hosts order)
sun00!/usr2/tmp-3%  env RESOLV_SERV_ORDER=nis,hosts a.out 192.9.200.2
Canonical name sun02
aliases:
  nonstop
  #		<==== Ugh! What is this?
  9405		<==== Oh,
  ch		<==== No!

sun00!/usr2/tmp-4%  egrep sun02 /etc/hosts
192.9.200.2	sun02	nonstop # 9405 ch <==	looks like
sun00!/usr2/tmp-5%  exit			NIS doesn't handle
sun00!/usr2/tmp-6%				'#' in the middle of
						a line as comment!
script done on Sat Mar	4 06:41:19 1995


If aliases returned by the library are so bogus, things get tough for
sysadmins. 

My conclusion is some of the bug of the NIS on old Sun system may have 
propagated and the recent resolv+ code is not protected against this
bug as well.
But I am not sure if this is the same bug mentioned in the previous
post.


Again, sorry for my bounced mails, and
appreciate if there is a digest version of this list (and how to
subscribe to it).

Regards,



-- 
     Chiaki Ishikawa         	ishikawa@personal-media.co.jp             
    Personal Media Corp.                  
  Shinagawa, Tokyo, Japan 141


|It's reported that Canter & Siegel search for and archive all articles
|that contain their names or "Green Card".  This .sig is to help them.